package com.wang.JinDong2;

import java.util.ArrayList;
import java.util.Scanner;


/**
 * 商城模块
 */
public class Store {
    static ArrayList<Product> list= new ArrayList<>();
    static {
        Product p = new ProductInShop(1111,"键盘",150,"蓝色",15,20);
        list.add(p);
    }
    static Scanner input = new Scanner(System.in);
    int num;

    public static void add(int id,String name,int price,String color,int size,int store){
        list.add(new ProductInShop(id,name,price,color,size,store));

    }

    public static void showAll(){
        if(Store.list.size()==0){
            System.out.println("当前无任何产品,请等待卖家添加商品");
            return;
        }else {
            Store.titleFrame();
            for(Product p :Store.list){
                p.show();
            }
        }
    }


    //添加购物车时，进行商品检查
    public static void check(int id){
        if(Store.list.size()==0){
            System.out.println("当前无任何产品，请等待卖家添加产品");
            Pause.pause();
            return;
        }else {
            for(Product p :Store.list){
                ProductInShop tempP= (ProductInShop)p;
                if(tempP.getId()==id){
                    tempP.show();
                    return;
                }
            }
        }
        System.out.println("未找到此编号的产品");
        Pause.pause();
    }

    //商品展示头
    public static void titleFrame(){
        System.out.println("编号\t\t商品名称\t\t价格\t颜色\t\t尺寸\t数量");
    }



}
